<script setup>
import { ChatDotRound } from '@element-plus/icons-vue'
import { ref, onMounted, onUpdated } from 'vue'
import GaodeMap from '@/components/GaodeMap.vue'
var interestText = ref('感兴趣')
//从父组件接收工作的详细信息
const props = defineProps(['jobContent', 'city'])
//初始化第一个工作的详情内容
onMounted(() => {
  document.getElementById('job_desc_content').innerHTML =
    props.jobContent.jobDescription
})

//当切换不同的工作推荐卡片时更新，更新工作详情内容
onUpdated(() => {
  document.getElementById('job_desc_content').innerHTML =
    props.jobContent.jobDescription
})
</script>

<template>
  <div class="job_detail_box">
    <div class="job_detail_header">
      <div class="job_header_info">
        <div class="job_detail_info">
          <span class="job_name">{{ jobContent.jobName }}</span>
          <span class="job_salary">15-25k·13薪</span>
        </div>
        <ul class="tag_list">
          <li>
            <Location style="width: 1em; height: 1em; margin-right: 6px" />
            <a class="tag_address" href="">东莞</a>
          </li>
          <li>
            <Suitcase style="width: 1em; height: 1em; margin-right: 6px" />
            1-3年
          </li>
          <li>
            <School style="width: 1em; height: 1em; margin-right: 6px" />
          </li>
          初中及以下
        </ul>
      </div>
      <div class="job_detail_op">
        <div
          class="op_btn_like"
          @click="
            interestText = interestText === '感兴趣' ? '取消感兴趣' : '感兴趣'
          "
        >
          <Star style="width: 1em; height: 1em; margin-right: 4px" />
          {{ interestText }}
        </div>
        <a href="/inform" class="op_btn_chat">立即沟通</a>
      </div>
    </div>
    <div class="job_detail_body">
      <h3 style="color: #222; font-weight: 600; line-height: 22px">职位描述</h3>
      <div class="job_detail_operate">
        <a href="#">
          <ChatDotRound
            style="width: 1em; height: 1em; margin-right: 4px"
          />微信扫码分享
        </a>
        <a href="#" style="margin-left: 20px">
          <WarnTriangleFilled
            style="width: 1em; height: 1em; margin-right: 4px"
          />举报
        </a>
      </div>
      <ul class="job_desc_label">
        <li v-for="(item, index) in jobContent.jobLabelList" :key="index">
          {{ item }}
        </li>
      </ul>
      <p id="job_desc_content"></p>
      <div class="job_boss_info">
        <img
          class="boss_avatar"
          :src="jobContent.companyBoss.bossAvatar"
          alt=""
        />
        <div class="boss_desc">
          <span class="boss_name">{{ jobContent.companyBoss.bossName }}</span>
          <i class="icon_vip"></i>
          <span class="boss_active_time">本周活跃</span>
          <div class="boss_desc_label">
            {{ jobContent.companyBoss.bossDescription }}
          </div>
        </div>
      </div>
      <div class="job_address">
        <div class="job_address_title">工作地址:</div>
        <div class="job_address_desc">
          <Location style="width: 1em; height: 1em; margin-right: 6px" />{{
            jobContent.jobAddress
          }}
        </div>
        <div class="gaode_map">
          <!-- {{ jobContent.companyMap }} -->
          <gaode-map
            :city="city"
            :address="jobContent.jobAddress"
            :mapImage="jobContent.companyMap"
          ></gaode-map
          ><!-- 不要给地图组件添加下边距 -->
        </div>
      </div>
      <a href="/jobDetail" class="more_job_btn">查看更多信息</a>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.job_detail_box {
  width: 100%;
  background-color: #fff;
  border-radius: 16px;
  .job_detail_header {
    padding: 16px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .job_header_info {
      .job_detail_info {
        display: flex;
        align-items: center;
        .job_name {
          max-width: 334px;
          font-size: 20px;
          font-weight: 600;
          color: #222;
          line-height: 28px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .job_salary {
          font-size: 24px;
          font-family: kanzhun-mix, kanzhun-Regular;
          color: #fe574a;
          line-height: 29px;
          flex-shrink: 0;
          margin-left: 20px;
        }
      }
      .tag_list {
        overflow: hidden;
        height: 20px;
        margin-top: 12px;
        display: flex;
        li {
          position: relative;
          color: #222;
          line-height: 20px;
          font-size: 14px;
          display: flex;
          align-items: center;
        }
        li:not(:first-child) {
          margin-left: 20px;
        }
      }
    }
    .job_detail_op {
      display: flex;
      font-size: 14px;
      .op_btn_like {
        width: 104px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 6px 0;
        line-height: 20px;
        color: #6f9edf;
        border: 1px solid #6f9edf;
        border-radius: 8px;
        cursor: pointer;
      }
      :hover {
        background: #e4f3ff;
      }
      .op_btn_chat {
        margin-left: 12px;
        width: 104px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 6px 0;
        line-height: 20px;
        color: #fff;
        background-color: rgb(89, 164, 255);
        border-radius: 8px;
        cursor: pointer;
      }
      .op_btn_chat:hover {
        background-color: rgba(124, 187, 255, 0.8);
      }
    }
  }
  .job_detail_body {
    max-height: calc(100vh - 262px); //相对于视口的剩余高度
    padding: 16px 30px 14px;
    position: relative;
    overflow: auto;
    scrollbar-width: thin;
    .job_detail_operate {
      position: absolute;
      display: flex;
      top: 16px;
      right: 30px;
      a {
        display: flex;
        align-items: center;
        color: #999;
        &:hover {
          color: #6f9edf;
        }
      }
    }
    .job_desc_label {
      margin-top: 12px;
      display: flex;
      flex-wrap: wrap;
      margin-left: -4px;
      li {
        background: #f8f8f8;
        border-radius: 4px;
        padding: 4px 12px;
        font-size: 13px;
        color: #666;
        line-height: 20px;
        margin: 4px;
      }
    }
    #job_desc_content {
      margin-top: 16px;
    }
    .job_boss_info {
      display: flex;
      align-items: center;
      border-top: 1px solid #ededed;
      border-bottom: 1px solid #ededed;
      padding: 16px 0;
      margin: 24px 0 16px 0;
      .boss_avatar {
        height: 40px;
        height: 40px;
        border-radius: 100%;
        margin-right: 12px;
      }
      .boss_desc {
        .boss_name {
          font-size: 16px;
          font-weight: 500;
          color: #222;
          line-height: 22px;
        }
        .icon_vip {
          display: inline-block;
          vertical-align: middle;
          width: 16px;
          height: 16px;
          margin-left: 8px;
          background: url('@/assets/recommend/vip.png') no-repeat center/contain;
        }
        .boss_active_time {
          display: inline-block;
          font-size: 12px;
          color: #999;
          line-height: 22px;
          margin-left: 16px;
          font-weight: 400;
        }
        .boss_desc_label {
          font-size: 12px;
          color: #666;
          line-height: 17px;
          margin-top: 4px;
        }
      }
    }
    .job_address {
      .job_address_title {
        font-size: 16px;
        font-weight: 600;
        color: #222;
        line-height: 22px;
      }
      .job_address_desc {
        margin-top: 12px;
        display: flex;
        align-items: center;
        font-size: 14px;
        color: #333;
        line-height: 20px;
      }
      .gaode_map {
        margin-top: 15px;
        width: 100%;
        height: 150px;
        border-radius: 15px;
      }
    }
    .more_job_btn {
      margin: 24px auto 0;
      display: block;
      width: 184px;
      padding: 9px 0;
      text-align: center;
      border-radius: 6px;
      border: 1px solid rgba(124, 187, 255, 0.8);
      font-size: 14px;
      color: #6f9edf;
      line-height: 20px;
      &:hover {
        background-color: rgba(200, 227, 255, 0.8);
      }
    }
  }
}
</style>
